package com.fh.shop.api.mq.producer;

import com.alibaba.fastjson.JSON;
import com.fh.shop.api.mq.config.MQConstant;
import com.fh.shop.api.mq.message.PayMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PayProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendPayMessage(PayMessage payMessage) {
        String payJson = JSON.toJSONString(payMessage);
        rabbitTemplate.convertAndSend(MQConstant.Pay.EX, "", payJson);
    }
}
